package com.cws.controller;



import cn.hutool.json.JSON;
import cn.hutool.json.JSONUtil;
import com.cws.common.Result;
import com.cws.utils.HttpUtils;
import com.cws.utils.PushUtil;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.HashMap;

/**
 * 测试手动推送
 */
@RestController
@Api("测试控制器")
public class TestController {

    //发出一次消息推送
    @RequestMapping("test")
    public String test() throws IOException {
        return PushUtil.push();
    }

    @RequestMapping("getPhoneMessage")
    public Result test2(@RequestParam(value ="phoneNum")String phoneNum) throws IOException {
        String msg = HttpUtils.sendGet("https://api.vvhan.com/api/phone/" + phoneNum, new HashMap<>());
        JSON phoneMessage = JSONUtil.parse(msg);
        return Result.success(phoneMessage);
    }
}
